'use client'

import { Moon, Sun } from 'lucide-react'
import { useTheme } from 'next-themes'
import * as React from 'react'

import { Button } from '@/components/ui/button'

export function ThemeButton() {
  const { theme, setTheme } = useTheme()
  if (!theme) return null
  const isLight = theme === 'light'

  return (
    <Button
      variant="outline"
      size="icon"
      onClick={() => setTheme(isLight ? 'dark' : 'light')}
    >
      {isLight ? <Moon className="h-4 w-4" /> : <Sun className="h-4 w-4" />}
    </Button>
  )
}
